#!/bin/bash


LIB_DIR=../lib
JPEG_DIR=../lib/jpeg
FFT_DIR=../lib/FFT
GSM_DIR=../lib/gsm
MIPS_DIR=../mips

today=$(date "+%Y.%m.%d,%H:%M:%S")

execute(){
    if [ "${3}" != "" ]
    then
	mips1.x --load=${2}  > ${3}
    else
	mips1.x --load=${2}
    fi
}


CURR_DIR=$(pwd)    

cd ${CURR_DIR}
execute  "hello" "hello.mips" ""




cd ${CURR_DIR}
echo "Executing for JPEG (small)"
cd ${JPEG_DIR}
mkdir -p output
execute "jpeg" "bin/cjpeg -dct int -progressive -opt -outfile output/output_small_encode.jpeg input/input_small.ppm" "/dev/null"
rm -rf output



cd ${CURR_DIR}
echo "Executing FFT (small)"
cd ${FFT_DIR}
mkdir -p output
execute "fft" "bin/fft 4 4096" "output/output_small.txt"
rm -rf output



cd ${CURR_DIR}
echo "Executing for GSM coder (large)"
cd ${GSM_DIR}
mkdir -p output
execute "gsm" "bin/toast -fps -c input/large.au" "output/output_large.encode.gsm"
rm -rf output

